// protocol.h

#ifndef PROTOCOL_H
#define PROTOCOL_H

#include <cstdint>
#include <visibility.h>

class SerialPort;


class __EXPORT Protocol
{
public:
	Protocol(SerialPort *rs, uint8_t *buffer, int size);
	~Protocol();
	
	uint8_t *getDataPointer();
	int getMaxDataSize() const;
	
	bool send(uint8_t addr, uint8_t id, int size);
	bool send(uint8_t addr, uint8_t id, const uint8_t *data, int size);	
	bool receive(uint8_t &addr, uint8_t &id, int &size);
	bool request(uint8_t addr, uint8_t id, int& size);
	bool request(uint8_t addr, uint8_t id, uint8_t *data, int dataSize, uint8_t *resp, int &respSize);
	
private:
	Protocol();
	
	SerialPort *rs_;
	uint8_t *buffer_;
	const int buffer_size_;
};


#endif
